﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace CapstoneProjectAEReader.Entities.Models
{
    [Serializable()]
    public class DTO : ISerializable
    {
        private List<Ebook> _ebooks = new List<Ebook>();
        private List<NoteDetail> _noteDetail = new List<NoteDetail>();
        private List<Note> _note = new List<Note>();
        private List<EbookGroup> _ebookGroup = new List<EbookGroup>();
        private List<Bookmark> _bookmark = new List<Bookmark>();
        private SettingDetail _settingDetail = new SettingDetail();

        public DTO() { }

        public SettingDetail SettingDetail
        {
            get { return _settingDetail; }
            set { _settingDetail = value; }
        }

        public List<Ebook> Ebooks
        {
            get { return _ebooks; }
            set { _ebooks = value; }
        }
        
        public List<NoteDetail> NoteDetail
        {
            get { return _noteDetail; }
            set { _noteDetail = value; }
        }

        public List<Note> Note
        {
            get { return _note; }
            set { _note = value; }
        }

        public List<EbookGroup> EbookGroup
        {
            get { return _ebookGroup; }
            set { _ebookGroup = value; }
        }

        public List<Bookmark> Bookmark
        {
            get { return _bookmark; }
            set { _bookmark = value; }
        }

        // Serialize
        public DTO(SerializationInfo info, StreamingContext ctxt)
        {
            EbookGroup = (List<EbookGroup>)info.GetValue("EbookGroup", typeof(List<EbookGroup>));
            Bookmark = (List<Bookmark>)info.GetValue("Bookmark", typeof(List<Bookmark>));
            Note = (List<Note>)info.GetValue("Note", typeof(List<Note>));
            NoteDetail = (List<NoteDetail>)info.GetValue("NoteDetail", typeof(List<NoteDetail>));
            Ebooks = (List<Ebook>)info.GetValue("Ebooks", typeof(List<Ebook>));
            SettingDetail = (SettingDetail)info.GetValue("SettingDetail", typeof(SettingDetail));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("EbookGroup", EbookGroup);
            info.AddValue("Bookmark", Bookmark);
            info.AddValue("Note", Note);
            info.AddValue("NoteDetail", NoteDetail);
            info.AddValue("Ebooks", Ebooks);
            info.AddValue("SettingDetail", SettingDetail);
        }
    }
}
